package com.boarsoft.boar.batch.demo.flow;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.boarsoft.boar.batch.demo.biz.DemoBatchBiz;
import com.boarsoft.boar.batch.demo.entity.Demo1;
import com.boarsoft.flow.core.bean.ProcessHandler;
import com.boarsoft.hibernate.biz.SimpleBizImpl;

public class DemoFlowBatchProcess_2 extends SimpleBizImpl implements ProcessHandler {
	@Autowired
	protected DemoBatchBiz biz;

	/**
	 * 
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Object process(String entry, Object data, Throwable throwable) throws Throwable {
		Map<String, Object> pm = (Map<String, Object>) data;
		final int pageNo = (Integer) pm.get("pageNo");
		StringBuilder sb = new StringBuilder();
		sb.append("from ").append(Demo1.class.getName()).append(" order by id");
		List<Demo1> lt = dao.list(sb.toString(), pageNo, 2000);
		for (Demo1 o: lt) {
			o.setF2("-");
		}
		dao.batchUpdate(lt, 500);
		return data;
	}
}
